package com.android.broad.listener;

import android.content.Context;

public abstract class Listener {
  private boolean registered;

  public boolean isRegistered() {
    return registered;
  }

  public boolean register(final Context context) {
    registered = false;
    if (registerImpl(context)) {
      registered = true;
      return true;
    }
    return false;
  }

  protected abstract boolean registerImpl(final Context context);

  public boolean unregister(final Context context) {
    if (unregisterImpl(context)) {
      registered = false;
      return true;
    }
    return false;
  }

  protected abstract boolean unregisterImpl(final Context context);
}
